Repetier-Firmware  1.0.0
PrintLine Class Reference

#include <motion.h>

Public Member Functions

bool areParameterUpToDate ()
 
void invalidateParameter ()
 
void setParameterUpToDate ()
 
bool isStartSpeedFixed ()
 
void setStartSpeedFixed (bool newState)
 
void fixStartAndEndSpeed ()
 
bool isEndSpeedFixed ()
 
void setEndSpeedFixed (bool newState)
 
bool isWarmUp ()
 
uint8_t getWaitForXLinesFilled ()
 
void setWaitForXLinesFilled (uint8_t b)
 
bool isExtruderForwardMove ()
 
void block ()
 
void unblock ()
 
bool isBlocked ()
 
bool isAllEMotors ()
 
bool isCheckEndstops ()
 
bool isNominalMove ()
 
void setNominalMove ()
 
void checkEndstops ()
 
void setXMoveFinished ()
 
void setYMoveFinished ()
 
void setZMoveFinished ()
 
void setXYMoveFinished ()
 
bool isXPositiveMove ()
 
bool isXNegativeMove ()
 
bool isYPositiveMove ()
 
bool isYNegativeMove ()
 
bool isZPositiveMove ()
 
bool isZNegativeMove ()
 
bool isEPositiveMove ()
 
bool isENegativeMove ()
 
bool isXMove ()
 
bool isYMove ()
 
bool isXOrYMove ()
 
bool isXOrZMove ()
 
bool isZMove ()
 
bool isEMove ()
 
bool isEOnlyMove ()
 
bool isNoMove ()
 
bool isXYZMove ()
 
bool isMoveOfAxis (uint8_t axis)
 
void setMoveOfAxis (uint8_t axis)
 
void setPositiveDirectionForAxis (uint8_t axis)
 
void updateAdvanceSteps (speed_t v, uint8_t max_loops, bool accelerate)
 
INLINE bool moveDecelerating ()
 
INLINE bool moveAccelerating ()
 
INLINE void startXStep ()
 
INLINE void startYStep ()
 
INLINE void startZStep ()
 
void updateStepsParameter ()
 
float safeSpeed (fast8_t drivingAxis)
 
void calculateMove (float axis_diff[], uint8_t pathOptimize, fast8_t distanceBase)
 
void logLine ()
 
INLINE long getWaitTicks ()
 
INLINE void setWaitTicks (long wait)
 
uint16_t calculateNonlinearSubSegments (uint8_t softEndstop)
 

Static Public Member Functions

static void resetPathPlanner ()
 
static INLINE bool hasLines ()
 
static INLINE void setCurrentLine ()
 
static INLINE void removeCurrentLineForbidInterrupt ()
 
static INLINE void pushLine ()
 
static uint8_t getLinesCount ()
 
static PrintLine * getNextWriteLine ()
 
static void computeMaxJunctionSpeed (PrintLine *previous, PrintLine *current)
 
static int32_t bresenhamStep ()
 
static void waitForXFreeLines (uint8_t b=1, bool allowMoves=false)
 
static void forwardPlanner (ufast8_t p)
 
static void backwardPlanner (ufast8_t p, ufast8_t last)
 
static void updateTrapezoids ()
 
static uint8_t insertWaitMovesIfNeeded (uint8_t pathOptimize, uint8_t waitExtraLines)
 
static void LaserWarmUp (uint32_t wait)
 
static void queueCartesianMove (uint8_t check_endstops, uint8_t pathOptimize)
 
static void queueCartesianSegmentTo (uint8_t check_endstops, uint8_t pathOptimize)
 
static void moveRelativeDistanceInSteps (int32_t x, int32_t y, int32_t z, int32_t e, float feedrate, bool waitEnd, bool check_endstop, bool pathOptimize=true)
 
static void moveRelativeDistanceInStepsReal (int32_t x, int32_t y, int32_t z, int32_t e, float feedrate, bool waitEnd, bool pathOptimize=true)
 
static void arc (float *position, float *target, float *offset, float radius, uint8_t isclockwise)
 
static INLINE void previousPlannerIndex (ufast8_t &p)
 
static INLINE void nextPlannerIndex (ufast8_t &p)
 
static uint8_t queueNonlinearMove (uint8_t check_endstops, uint8_t pathOptimize, uint8_t softEndstop)
 
static void queueEMove (int32_t e_diff, uint8_t check_endstops, uint8_t pathOptimize)
 
static void calculateDirectionAndDelta (int32_t difference[], ufast8_t *dir, int32_t delta[])
 
static uint8_t calculateDistance (float axis_diff[], uint8_t dir, float *distance)
 
static void calculatePlane (int32_t factors[], int32_t p1[], int32_t p2[], int32_t p3[])
 
static float calcZOffset (int32_t factors[], int32_t pointX, int32_t pointY)
 

Public Attributes

ufast8_t joinFlags
 
volatile ufast8_t flags
 
secondspeed_t secondSpeed
 
int32_t stepsRemaining
 Remaining steps, until move is finished. More...
 

Static Public Attributes

static ufast8_t linesPos = 0
 Position for executing line movement. More...
 
static PrintLine lines []
 Cache for print moves. More...
 
static ufast8_t linesWritePos = 0
 Position where we write the next cached line move. More...
 
static PrintLine * cur = NULL
 Current printing line. More...
 
static volatile ufast8_t linesCount = 0
 Number of lines cached 0 = nothing to do. More...
 

Private Attributes

fast8_t primaryAxis
 
ufast8_t dir
 Direction of movement. 1 = X+, 2 = Y+, 4= Z+, values can be combined. More...
 
int32_t timeInTicks
 
int32_t delta [E_AXIS_ARRAY]
 Steps we want to move. More...
 
int32_t error [E_AXIS_ARRAY]
 Error calculation for Bresenham algorithm. More...
 
float speedX
 Speed in x direction at fullInterval in mm/s. More...
 
float speedY
 Speed in y direction at fullInterval in mm/s. More...
 
float speedZ
 Speed in z direction at fullInterval in mm/s. More...
 
float speedE
 Speed in E direction at fullInterval in mm/s. More...
 
float fullSpeed
 Desired speed mm/s. More...
 
float invFullSpeed
 1.0/fullSpeed for faster computation More...
 
float accelerationDistance2
 Real 2.0*distance*acceleration mm²/s² More...
 
float maxJunctionSpeed
 Max. junction speed between this and next segment. More...
 
float startSpeed
 Starting speed in mm/s. More...
 
float endSpeed
 Exit speed in mm/s. More...
 
float minSpeed
 
float distance
 
uint8_t numNonlinearSegments
 Number of delta segments left in line. Decremented by stepper timer. More...
 
uint8_t moveID
 ID used to identify moves which are all part of the same line. More...
 
int32_t numPrimaryStepPerSegment
 Number of primary Bresenham axis steps in each delta segment. More...
 
NonlinearSegment segments [DELTASEGMENTS_PER_PRINTLINE]
 
ticks_t fullInterval
 interval at full speed in ticks/step. More...
 
uint32_t accelSteps
 How much steps does it take, to reach the plateau. More...
 
uint32_t decelSteps
 How much steps does it take, to reach the end speed. More...
 
uint32_t accelerationPrim
 Acceleration along primary axis. More...
 
uint32_t fAcceleration
 accelerationPrim*262144/F_CPU More...
 
speed_t vMax
 Maximum reached speed in steps/s. More...
 
speed_t vStart
 Starting speed in steps/s. More...
 
speed_t vEnd
 End speed in steps/s. More...
 

Static Private Attributes

static volatile bool nlFlag
 

Friends

class UIDisplay
 

Member Function Documentation

◆ arc()

void PrintLine::arc ( float *  position,
float *  target,
float *  offset,
float  radius,
uint8_t  isclockwise 
)
static

◆ areParameterUpToDate()

bool PrintLine::areParameterUpToDate ( )
inline

◆ backwardPlanner()

void PrintLine::backwardPlanner ( ufast8_t  start,
ufast8_t  last 
)
inlinestatic

Compute the maximum speed from the last entered move. The backwards planner traverses the moves from last to first looking at deceleration. The RHS of the accelerate/decelerate ramp.

start = last line inserted last = last element until we check

◆ block()

void PrintLine::block ( )
inline

◆ bresenhamStep()

int32_t PrintLine::bresenhamStep ( )
static

◆ calculateDirectionAndDelta()

static void PrintLine::calculateDirectionAndDelta ( int32_t  difference[],
ufast8_t *  dir,
int32_t  delta[] 
)
inlinestatic

◆ calculateDistance()

static uint8_t PrintLine::calculateDistance ( float  axis_diff[],
uint8_t  dir,
float *  distance 
)
inlinestatic

◆ calculateMove()

void PrintLine::calculateMove ( float  axis_diff[],
uint8_t  pathOptimize,
fast8_t  distanceBase 
)

◆ calculateNonlinearSubSegments()

uint16_t PrintLine::calculateNonlinearSubSegments ( uint8_t  softEndstop)
inline

◆ calculatePlane()

static void PrintLine::calculatePlane ( int32_t  factors[],
int32_t  p1[],
int32_t  p2[],
int32_t  p3[] 
)
static

◆ calcZOffset()

static float PrintLine::calcZOffset ( int32_t  factors[],
int32_t  pointX,
int32_t  pointY 
)
static

◆ checkEndstops()

void PrintLine::checkEndstops ( )
inline

◆ computeMaxJunctionSpeed()

void PrintLine::computeMaxJunctionSpeed ( PrintLine *  previous,
PrintLine *  current 
)
inlinestatic

◆ fixStartAndEndSpeed()

void PrintLine::fixStartAndEndSpeed ( )
inline

◆ forwardPlanner()

void PrintLine::forwardPlanner ( ufast8_t  p)
inlinestatic

◆ getLinesCount()

static uint8_t PrintLine::getLinesCount ( )
inlinestatic

◆ getNextWriteLine()

static PrintLine* PrintLine::getNextWriteLine ( )
inlinestatic

◆ getWaitForXLinesFilled()

uint8_t PrintLine::getWaitForXLinesFilled ( )
inline

◆ getWaitTicks()

INLINE long PrintLine::getWaitTicks ( )
inline

◆ hasLines()

static INLINE bool PrintLine::hasLines ( )
inlinestatic

◆ insertWaitMovesIfNeeded()

uint8_t PrintLine::insertWaitMovesIfNeeded ( uint8_t  pathOptimize,
uint8_t  waitExtraLines 
)
static

Check if move is new. If it is insert some dummy moves to allow the path optimizer to work since it does not act on the first two moves in the queue. The stepper timer will spot these moves and leave some time for processing.

◆ invalidateParameter()

void PrintLine::invalidateParameter ( )
inline

◆ isAllEMotors()

bool PrintLine::isAllEMotors ( )
inline

◆ isBlocked()

bool PrintLine::isBlocked ( )
inline

◆ isCheckEndstops()

bool PrintLine::isCheckEndstops ( )
inline

◆ isEMove()

bool PrintLine::isEMove ( )
inline

◆ isEndSpeedFixed()

bool PrintLine::isEndSpeedFixed ( )
inline

◆ isENegativeMove()

bool PrintLine::isENegativeMove ( )
inline

◆ isEOnlyMove()

bool PrintLine::isEOnlyMove ( )
inline

◆ isEPositiveMove()

bool PrintLine::isEPositiveMove ( )
inline

◆ isExtruderForwardMove()

bool PrintLine::isExtruderForwardMove ( )
inline

◆ isMoveOfAxis()

bool PrintLine::isMoveOfAxis ( uint8_t  axis)
inline

◆ isNominalMove()

bool PrintLine::isNominalMove ( )
inline

◆ isNoMove()

bool PrintLine::isNoMove ( )
inline

◆ isStartSpeedFixed()

bool PrintLine::isStartSpeedFixed ( )
inline

◆ isWarmUp()

bool PrintLine::isWarmUp ( )
inline

◆ isXMove()

bool PrintLine::isXMove ( )
inline

◆ isXNegativeMove()

bool PrintLine::isXNegativeMove ( )
inline

◆ isXOrYMove()

bool PrintLine::isXOrYMove ( )
inline

◆ isXOrZMove()

bool PrintLine::isXOrZMove ( )
inline

◆ isXPositiveMove()

bool PrintLine::isXPositiveMove ( )
inline

◆ isXYZMove()

bool PrintLine::isXYZMove ( )
inline

◆ isYMove()

bool PrintLine::isYMove ( )
inline

◆ isYNegativeMove()

bool PrintLine::isYNegativeMove ( )
inline

◆ isYPositiveMove()

bool PrintLine::isYPositiveMove ( )
inline

◆ isZMove()

bool PrintLine::isZMove ( )
inline

◆ isZNegativeMove()

bool PrintLine::isZNegativeMove ( )
inline

◆ isZPositiveMove()

bool PrintLine::isZPositiveMove ( )
inline

◆ LaserWarmUp()

void PrintLine::LaserWarmUp ( uint32_t  wait)
static

◆ logLine()

void PrintLine::logLine ( )

◆ moveAccelerating()

INLINE bool PrintLine::moveAccelerating ( )
inline

◆ moveDecelerating()

INLINE bool PrintLine::moveDecelerating ( )
inline

◆ moveRelativeDistanceInSteps()

void PrintLine::moveRelativeDistanceInSteps ( int32_t  x,
int32_t  y,
int32_t  z,
int32_t  e,
float  feedrate,
bool  waitEnd,
bool  checkEndstop,
bool  pathOptimize = true 
)
static

Move printer the given number of steps. Puts the move into the queue. Used by e.g. homing commands. Does not consider rotation but updates position correctly considering rotation. This can be used to correct positions when changing tools.

Parameters
xDistance in x direction in steps
yDistance in y direction in steps
zDistance in z direction in steps
eDistance in e direction in steps
feedrateFeed rate to be used in mm/s. Gets new active feedrate.
waitEndIf true will block until move is finished.
checkEndstopTrue if triggering endstop should stop move.
pathOptimizeIf false start and end speeds get fixed to minimum values.

◆ moveRelativeDistanceInStepsReal()

void PrintLine::moveRelativeDistanceInStepsReal ( int32_t  x,
int32_t  y,
int32_t  z,
int32_t  e,
float  feedrate,
bool  waitEnd,
bool  pathOptimize = true 
)
static

Adds the steps converted to mm to the lastCmdPos position and moves to that position using Printer::moveToReal. Will use Printer::isPositionAllowed to prevent illegal moves.

Parameters
xDistance in x direction in steps
yDistance in y direction in steps
zDistance in z direction in steps
eDistance in e direction in steps
feedrateFeed rate to be used in mm/s. Gets new active feedrate.
waitEndIf true will block until move is finished.
pathOptimizeIf false start and end speeds get fixed to minimum values.

◆ nextPlannerIndex()

static INLINE void PrintLine::nextPlannerIndex ( ufast8_t &  p)
inlinestatic

◆ previousPlannerIndex()

static INLINE void PrintLine::previousPlannerIndex ( ufast8_t &  p)
inlinestatic

◆ pushLine()

static INLINE void PrintLine::pushLine ( )
inlinestatic

◆ queueCartesianMove()

void PrintLine::queueCartesianMove ( uint8_t  check_endstops,
uint8_t  pathOptimize 
)
static

Put a move to the current destination coordinates into the movement cache. If the cache is full, the method will wait, until a place gets free. During wait communication and temperature control is enabled.

destinationSteps must be excluding any z correction! We will add that if required here.

Parameters
check_endstopsRead end stop during move.

◆ queueCartesianSegmentTo()

void PrintLine::queueCartesianSegmentTo ( uint8_t  check_endstops,
uint8_t  pathOptimize 
)
static

◆ queueEMove()

static void PrintLine::queueEMove ( int32_t  e_diff,
uint8_t  check_endstops,
uint8_t  pathOptimize 
)
inlinestatic

◆ queueNonlinearMove()

static uint8_t PrintLine::queueNonlinearMove ( uint8_t  check_endstops,
uint8_t  pathOptimize,
uint8_t  softEndstop 
)
static

◆ removeCurrentLineForbidInterrupt()

static INLINE void PrintLine::removeCurrentLineForbidInterrupt ( )
inlinestatic

◆ resetPathPlanner()

static void PrintLine::resetPathPlanner ( )
inlinestatic

◆ safeSpeed()

float PrintLine::safeSpeed ( fast8_t  drivingAxis)
inline

◆ setCurrentLine()

static INLINE void PrintLine::setCurrentLine ( )
inlinestatic

◆ setEndSpeedFixed()

void PrintLine::setEndSpeedFixed ( bool  newState)
inline

◆ setMoveOfAxis()

void PrintLine::setMoveOfAxis ( uint8_t  axis)
inline

◆ setNominalMove()

void PrintLine::setNominalMove ( )
inline

◆ setParameterUpToDate()

void PrintLine::setParameterUpToDate ( )
inline

◆ setPositiveDirectionForAxis()

void PrintLine::setPositiveDirectionForAxis ( uint8_t  axis)
inline

◆ setStartSpeedFixed()

void PrintLine::setStartSpeedFixed ( bool  newState)
inline

◆ setWaitForXLinesFilled()

void PrintLine::setWaitForXLinesFilled ( uint8_t  b)
inline

◆ setWaitTicks()

INLINE void PrintLine::setWaitTicks ( long  wait)
inline

◆ setXMoveFinished()

void PrintLine::setXMoveFinished ( )
inline

◆ setXYMoveFinished()

void PrintLine::setXYMoveFinished ( )
inline

◆ setYMoveFinished()

void PrintLine::setYMoveFinished ( )
inline

◆ setZMoveFinished()

void PrintLine::setZMoveFinished ( )
inline

◆ startXStep()

INLINE void PrintLine::startXStep ( )
inline

◆ startYStep()

INLINE void PrintLine::startYStep ( )
inline

◆ startZStep()

INLINE void PrintLine::startZStep ( )
inline

◆ unblock()

void PrintLine::unblock ( )
inline

◆ updateAdvanceSteps()

void PrintLine::updateAdvanceSteps ( speed_t  v,
uint8_t  max_loops,
bool  accelerate 
)
inline

◆ updateStepsParameter()

void PrintLine::updateStepsParameter ( )

Update parameter used by updateTrapezoids

Computes the acceleration/deceleration steps and advanced parameter associated.

◆ updateTrapezoids()

void PrintLine::updateTrapezoids ( )
static

This is the path planner.

It goes from the last entry and tries to increase the end speed of previous moves in a fashion that the maximum jerk is never exceeded. If a segment with reached maximum speed is met, the planner stops. Everything left from this is already optimal from previous updates. The first 2 entries in the queue are not checked. The first is the one that is already in print and the following will likely to become active.

The method is called before lines_count is increased!

◆ waitForXFreeLines()

void PrintLine::waitForXFreeLines ( uint8_t  b = 1,
bool  allowMoves = false 
)
static

Friends And Related Function Documentation

◆ UIDisplay

friend class UIDisplay
friend

Member Data Documentation

◆ accelerationDistance2

float PrintLine::accelerationDistance2
private

Real 2.0*distance*acceleration mm²/s²

◆ accelerationPrim

uint32_t PrintLine::accelerationPrim
private

Acceleration along primary axis.

◆ accelSteps

uint32_t PrintLine::accelSteps
private

How much steps does it take, to reach the plateau.

◆ cur

PrintLine * PrintLine::cur = NULL
static

Current printing line.

◆ decelSteps

uint32_t PrintLine::decelSteps
private

How much steps does it take, to reach the end speed.

◆ delta

int32_t PrintLine::delta[E_AXIS_ARRAY]
private

Steps we want to move.

◆ dir

ufast8_t PrintLine::dir
private

Direction of movement. 1 = X+, 2 = Y+, 4= Z+, values can be combined.

◆ distance

float PrintLine::distance
private

◆ endSpeed

float PrintLine::endSpeed
private

Exit speed in mm/s.

◆ error

int32_t PrintLine::error[E_AXIS_ARRAY]
private

Error calculation for Bresenham algorithm.

◆ fAcceleration

uint32_t PrintLine::fAcceleration
private

accelerationPrim*262144/F_CPU

◆ flags

volatile ufast8_t PrintLine::flags

◆ fullInterval

ticks_t PrintLine::fullInterval
private

interval at full speed in ticks/step.

◆ fullSpeed

float PrintLine::fullSpeed
private

Desired speed mm/s.

◆ invFullSpeed

float PrintLine::invFullSpeed
private

1.0/fullSpeed for faster computation

◆ joinFlags

ufast8_t PrintLine::joinFlags

◆ lines

PrintLine PrintLine::lines
static

Cache for print moves.

◆ linesCount

volatile ufast8_t PrintLine::linesCount = 0
static

Number of lines cached 0 = nothing to do.

◆ linesPos

ufast8_t PrintLine::linesPos = 0
static

Position for executing line movement.

◆ linesWritePos

ufast8_t PrintLine::linesWritePos = 0
static

Position where we write the next cached line move.

◆ maxJunctionSpeed

float PrintLine::maxJunctionSpeed
private

Max. junction speed between this and next segment.

◆ minSpeed

float PrintLine::minSpeed
private

◆ moveID

uint8_t PrintLine::moveID
private

ID used to identify moves which are all part of the same line.

◆ nlFlag

volatile bool PrintLine::nlFlag
staticprivate

◆ numNonlinearSegments

uint8_t PrintLine::numNonlinearSegments
private

Number of delta segments left in line. Decremented by stepper timer.

◆ numPrimaryStepPerSegment

int32_t PrintLine::numPrimaryStepPerSegment
private

Number of primary Bresenham axis steps in each delta segment.

◆ primaryAxis

fast8_t PrintLine::primaryAxis
private

◆ secondSpeed

secondspeed_t PrintLine::secondSpeed

◆ segments

NonlinearSegment PrintLine::segments[DELTASEGMENTS_PER_PRINTLINE]
private

◆ speedE

float PrintLine::speedE
private

Speed in E direction at fullInterval in mm/s.

◆ speedX

float PrintLine::speedX
private

Speed in x direction at fullInterval in mm/s.

◆ speedY

float PrintLine::speedY
private

Speed in y direction at fullInterval in mm/s.

◆ speedZ

float PrintLine::speedZ
private

Speed in z direction at fullInterval in mm/s.

◆ startSpeed

float PrintLine::startSpeed
private

Starting speed in mm/s.

◆ stepsRemaining

int32_t PrintLine::stepsRemaining

Remaining steps, until move is finished.

◆ timeInTicks

int32_t PrintLine::timeInTicks
private

◆ vEnd

speed_t PrintLine::vEnd
private

End speed in steps/s.

◆ vMax

speed_t PrintLine::vMax
private

Maximum reached speed in steps/s.

◆ vStart

speed_t PrintLine::vStart
private

Starting speed in steps/s.


The documentation for this class was generated from the following files: